package cn.amebius.simpledocker.controller.request;

import cn.amebius.simpledocker.exception.ParameterErrorException;
import lombok.Data;

/**
 * 重置密码请求
 * @author 阿伟
 * @date 2023/7/27 21:25
 */
@Data
public class ResetRequest {

    //8 ~ 40
    private String oldPassword;

    //8 ~ 40
    private String newPassword;
    public void checkParameter() {
        if (oldPassword.isEmpty() || newPassword.isEmpty()) {
            throw new ParameterErrorException("旧密码或新密码错误！");
        } else if (oldPassword.length() >= 40 || newPassword.length() >= 40) {
            throw new ParameterErrorException("新密码或旧密码太长");
        } else if (oldPassword.length() < 8 || newPassword.length() < 8) {
            throw new ParameterErrorException("新密码或旧密码太短");
        }
    }
}
